#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2019 crane <crane@gosun>
#
# Distributed under terms of the MIT license.

"""

"""

class Solution:
    def do_case(self, err_nums):
        self.err_nums = err_nums

        self.calc()

    def calc(self):
        if not self.err_nums:
            print(0)

        cur_value = 0           # 某天, 小明的能力值(第一天初始化为0)
        max_value = 0           # 小明历史最高能力值(初始化为第一天的能力值)

        min_err = max_err = self.err_nums[0]        # 历史天中: 最小的失误数

        for idx in range(1, len(self.err_nums)):
            # err_n : 当天失误值
            # 根据当天失误值, 计算cur_value, 和max_value
            err_n = self.err_nums[idx]

            if err_n < min_err:
                # 如果比之前所有天失误都小
                cur_value += 1
                max_value = max(max_value, cur_value)
            elif err_n > min_err:
                # 如果比之前所有天失误都小
                cur_value -= 1
            else:
                # 值一直没有变(实质上是当天失误值, 和历史最小失误值相同)
                pass

            min_err = min(min_err, err_n)

        # 输出最大值
        print(max_value)


s = Solution()
# s.do_case([ 3, 1, 2 ])
# s.do_case([5, 2, 1, 2, 3])

def do_one_case():
    n = int( input().strip() )
    err_nums = [int(e) for e in  input().strip().split()]

    s.do_case(err_nums)


def main():
    print("start main")

    t = int(input())
    for i in range(t):
        do_one_case()

if __name__ == "__main__":
    main()
